
#ifndef _MEMBER_BHTMLWIDGET_H_
#define _MEMBER_BHTMLWIDGET_H_

#include <ctime>
#include <BMap>
#include <BXmlNode>
#include <BHtmlWidget>

#define html_member(html)			((member_BHtmlWidget*)((BHtmlWidget*)html)->_ptr)

namespace BWE
{
	class member_BHtmlWidget
	{
	public:
		member_BHtmlWidget(BHtmlWidget* htmlWidget);
		~member_BHtmlWidget();

		void freshStyle(BHtmlItem* item);
		void freshArea();

		void paintItem(BHtmlItem* item, BPainter& painter);

		bool seekPrevWord();
		bool seekNextWord();
		bool seekPrev();
		bool seekNext();

		bool removeSelection();
		bool removeIndex();

		void itemTextEdited(BHtmlItem* item);

		BHtmlItem* itemAt(const BPoint& pos, BHtmlItem* item);
		BHtmlItem* itemOfId(BHtmlItem* item, const BString& id);

		BHtmlWidget*			boss;
		BString					fileName;
		Policy					pagePolicy;
		BHolder<BXmlNode>		rootNode;
		BHolder<BHtmlItem>		bodyItem;
		BReal					blinkTick;
		BReal					blinkTime;
		bool					inputShown;
		bool					readOnly;

		bool					dirty;
		bool					editing;
		int						pageWidth;
		BHtmlItem*				inputItem;
		BHtmlItem*				hoverItem;
		int						hoverIndex;
		int						pressed;
		int						pressIndex;
		BPoint					pressPoint;
		BMap<BString, BFontHolder>	fontMap;
	};
}

#endif
